import Vue from 'vue'
import VueRouter from 'vue-router'
const Login = () =>
    import ('@/views/login/login') //登录页面
const AccountPage = () =>
    import ('@/views/WorkBench/accountPage') //账号页面
const Workbench = () =>
    import ('@/views/WorkBench/workbench')
const WorkbenchDetail = () =>
    import ('@/views/WorkBench/workbenchDetail')
const OutsourcingNewApply = () =>
    import ('@/views/WorkBench/outsourcingNewApply') //工作台
const SettingPage = () =>
    import ('@/views/WorkBench/settingPage') //设置
const AskOff = () =>
    import ('@/views/WorkBench/askOff') //请假申请
const Missing = () =>
    import ('@/views/WorkBench/missing') //请假申请
const OverTime = () =>
    import ('@/views/WorkBench/overTime') //加班申请
const Management = () =>
    import ('@/views/WorkBench/management') //成员管理
const AddMember = () =>
    import ('@/views/WorkBench/addMember') //添加成员
const ImportingMembers = () =>
    import ('@/views/WorkBench/importingMembers') //导入成员
const MemberList = () =>
    import ('@/views/WorkBench/memberList') //导入成员
const LeaveManger = () =>
    import ('@/views/WorkBench/leaveManger') //假期管理
    // const SpacePage = () => import('@/views/WorkBench/spacePage')
const ComparExcel = () =>
    import ('@/views/compar/comparExcel') //文件对比
Vue.use(VueRouter)

const routes = [
    // {
    //   path: '/',
    //   name: 'spacePage',
    //   component: SpacePage,
    //   meta: {
    //     keepAlive: false
    //   }
    // },
    {
        path: '/',
        name: 'login',
        component: Login,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/login',
        name: 'login',
        component: Login,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/accountPage',
        name: 'accountPage',
        component: AccountPage,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/workbench',
        name: 'workbench',
        component: Workbench,
        meta: {
            keepAlive: true
        }
    },
    {
        path: '/workbenchDetail',
        name: 'workbenchDetail',
        component: WorkbenchDetail,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/outsourcingNewApply',
        name: 'outsourcingNewApply',
        component: OutsourcingNewApply,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/settingPage',
        name: 'settingPage',
        component: SettingPage,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/askOff',
        name: 'askOff',
        component: AskOff,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/overTime',
        name: 'overTime',
        component: OverTime,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/missing',
        name: 'missing',
        component: Missing,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/management',
        name: 'management',
        component: Management,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/addMember',
        name: 'addMember',
        component: AddMember,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/importingMembers',
        name: 'importingMembers',
        component: ImportingMembers,
        meta: {
            keepAlive: true
        }
    },
    {
        path: '/memberList',
        name: 'memberList',
        component: MemberList,
        meta: {
            keepAlive: false
        }
    },
    {
        path: '/comparExcel',
        name: 'comparExcel',
        component: ComparExcel,
        meta: {
            keepAlive: false
        }
    },
    // {
    //   path: '*',
    //   redirect: '/'
    // },
    {
        path: '/leaveManger',
        name: 'leaveManger',
        component: LeaveManger,
        meta: {
            keepAlive: true
        }
    }
]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
        routes
    })
    // router.beforeEach((to, from, next) => {
    // // 如果访问的是登录界面则直接放行
    // if (to.path === '/login') return next()
    // //获取用户页面token信息
    // let token = window.sessionStorage.getItem('token')
    // //如果token数据为null则跳转到指定路径
    // if (!token) return next("/login")
    // next()

// })
Vue.prototype.routerBase = [...routes]

router.$addRoute = params => {
    router.matcher = new VueRouter().matcher
    router.addRoute(params)
}

export default router